#!/usr/bin/env bash
dt="`date -d "$d  0 days ago "  "+%Y-%m-%d"`"
mysql -uroot -proot -hhadoop2<<EOF
use oraclecd;
SELECT from_unixtime(unix_timestamp(),'%Y-%m-%d'),A.GET,B.USED,A.GET-B.USED
FROM
(SELECT SUM(abs(AMOUNT))/100 AS GET
FROM TBL_TRADE WHERE TRADE_TYPE='103')AS A
JOIN
(SELECT SUM(abs(AMOUNT))/100 AS USED
FROM TBL_TRADE WHERE TRADE_TYPE='155' or TRADE_TYPE='158')AS B;
EOF